package com.nl.lib_core.view

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.widget.ImageView
import android.widget.RelativeLayout
import com.nl.lib_core.R
import com.nl.lib_core.tool.extends.loadImage

/** 作者: wangfei 创建时间: 2021/9/1 包名: com.nl.lib_core.view 类名: LoadingInitView */
class LoadingInitView(context: Context, attrs: AttributeSet) : RelativeLayout(context, attrs) {

  init {
    inflate(context, R.layout.core_view_init_loading, this)
    val attr = context.obtainStyledAttributes(attrs, R.styleable.LoadingInitView)
    val backgroundColor = attr.getColor(R.styleable.LoadingInitView_background_color, -1)
    if (backgroundColor != -1) {
      findViewById<RelativeLayout>(R.id.mParent).setBackgroundColor(backgroundColor)
    }
    attr.recycle()
    val imgLoading: ImageView = findViewById(R.id.img_init_loading)
    imgLoading.loadImage(context, R.drawable.core_loading, 0)
  }

  override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
    return true
  }
}
